(function() {
    angular.module('app').component('modalComponent', {
        templateUrl: 'app/components/modal.component/modal.component.html',
        controller: modalComponent,
        controllerAs: 'vm'

    });

    modalComponent.$inject = ['$rootScope','$scope'];

    function modalComponent($rootScope,$scope) {
        var vm = this;


        console.log('modal loading');
        $('#my-modal-box').modal();
        // $('#my-modal-box').modal('open');
        vm.modal = {};



        var clearFun = $rootScope.$on('MODAL_COMPONENT_EV', function(e, modal) {
            // console.log('modal is run');
            vm.modal = modal;
   
   
            $('#my-modal-box').modal('open');
        });

        vm.close = function() {
            $('#my-modal-box').modal('close');
        };

        $scope.$on('$destroy',function(){
        	clearFun();
        });
    }
})();
